/************************************************************************
 * File: board.h                                                        *
 *                                                                      *
 * Copyright 2006, 2008 Colin Kern (colin.kern@gmail.com)               *
 *                                                                      *
 * This file is part of Profit.  Some previous versions were released   *
 * under the names Megacorp Mania and Acquire.                          *
 *                                                                      *
 * Profit is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * any later version.                                                   *
 *                                                                      *
 * Profit is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with Profit.  If not, see <http://www.gnu.org/licenses/>.      *
 ************************************************************************/
#ifndef BOARD_H
#define BOARD_H

#include <QWidget>
#include <QList>
#include "tile.h"
#include "boardslot.h"

class Board : public QWidget
{
	Q_OBJECT
	
    public:
        Board(int rows = 0, int columns = 0, QWidget *parent = 0);
        
        const BoardSlot *getSlot(int row, int column) const;
        int nRows() const;
        int nColumns() const;
		QSize sizeHint() const;
        
        BoardSlot *getSlot(int row, int column);
		BoardSlot *getSlot(const Tile &tile);
        void reset();
		void removeTile(const Tile &tile, bool invisible = false);
		void highlightTile(const Tile &tile, BoardSlot::Highlight highlight);
        QList<Tile> placeTile(const Tile &tile, bool invisible = false);
        QList<Tile> adjacent(const Tile &tile);
        QList<Company*> findCompanies(const QList<Tile> &tiles);
		void clearHighlights();
		
	signals:
		void slotClicked(int row, int column);
		
	protected:
		void paintEvent(QPaintEvent *event);
		
    private:
        QList< QList<BoardSlot*> > m_board;
		QList<Tile> m_moves;
};

#endif
